#pragma once

#include "Part.h"
#include "Achievement/AchievementMgr.h"

class AchievementPart : public Part
{

public:
	typedef std::vector< AchievementPlayerSortInfo > AchievementPlayerSortInfoVector;

public:
	AchievementPart();
	virtual ~AchievementPart();
public:
	virtual bool		Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	virtual bool		UnInit();
	virtual bool		OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	virtual void		OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void		OnTimer(uint32_t nTimerID){}
	virtual bool		SaveDB(CharacterDBInfo& characterDB);
	virtual void		Update(uint64_t tick){}

private:
	bool				HandleGetAchievementInfoReq(const char* data, uint32_t len);			
	bool				HandleGetAchievementReward(const char* data, uint32_t len);
	bool				HandleGetAchievementBoxReward(const char* data, uint32_t len);

public:
	//功能接口
	virtual void		UpdateAchievement(AchievementParameterInfo& achievementParameter);
	//属性改变
	void				DoAttrChange(uint32_t PANum, int64_t nCurValue, int64_t nChangeValue = 0);
	//是否已经完成
	bool				FinishAchieve(uint32_t achieveId);

private:
	//检查成就
	bool				CheckAchieve(AchievementInfo &achievementInfo, AchievementParameterInfo& achievementParameter, const AchievementAchievementCfgInfo* pAchievementCfgInfo);
	//是否完成
	bool				FinishAchieve(const AchievementAchievementCfgInfo *pcfg);
	//更新成就接口
	bool				UpdateAchievement(AchievementParameterInfo& achievementParameter, GCAchievementNotify& acNotify);

	ERetCode			GetAchievementReward(uint32_t sortType, uint32_t achievementId);
	ERetCode			GetAchievementBoxReward(uint32_t prizeId);
public:

private:
	//成就大分类列表
	AchievementPlayerSortInfoVector _achievementMap;
};
